#include <stdio.h>
#include "lex.h"

int main(void){
  char* input = "this is an identifier\\(\\)\\  (\\) \"my string\"  thisis aaa bbbbbb";
  RLexer lexer;
  lexer.input = input;
  r_lex_init(&lexer, 2);
  r_lex_add(&lexer, "[a-z]+", 1, 0, 0); /* identifier */
  r_lex_add(&lexer, "is", 7, 0, 0);  /* keyword */
  r_lex_add(&lexer, "this", 8, 0, 0); /* keyword */
  r_lex_add(&lexer, " +", 0, 0, 0);
  r_lex_add(&lexer, "(\\\\|\\(|\\))+", 2, 0, 0);
  r_lex_add(&lexer, "\\\"", 0, 0, 1);
  r_lex_add(&lexer, "[^\\\"]+", 3, 1, 1);
  r_lex_add(&lexer, "\\\"", 0, 1, -1);
  RVector* token_list = r_lex_tokenize(&lexer);

  int i;
  for (i = 0; i < token_list->size; i++){
    RToken* token = r_vector_get(token_list, i);
    printf("i = %d, tok = %d, val = \"%s\"\n", i, token->type, (char*) token->extra);
  }

  return 0;
}
